package com.education.core.controller;

import com.education.common.base.BaseController;
import com.education.common.model.Captcha;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.security.PublicKey;

/**
 * 生成验证码接口
 * @author 余一
 * @date 2021/9/17  15:17
 */
@RestController
public class ImageController extends BaseController {


    @GetMapping("/api/image")
    public void image(HttpServletRequest request, HttpServletResponse response){
        String key = request.getParameter("key");
        //前端传递的key值作为redis缓存的key
        Captcha captcha = new Captcha(cacheBean, key);
        captcha.render(response);
    }
}
